package com.seven.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ai")
@RequiredArgsConstructor
public class AiController {

    private final ChatModel chatModel;

    private final ChatClient.Builder chatClientBuilder;

    private final ToolCallbackProvider tools;

    @GetMapping("/chat")
    public String generation(@RequestParam("prompt") String userInput) {
        return this.chatModel.call(userInput);
    }


    @GetMapping("/fcChat")
    public String fcChat(@RequestParam("prompt") String userInput) {
        ChatClient chatClient = chatClientBuilder
                .defaultTools(tools)
                .build();
        return chatClient.prompt(userInput).call().content();
    }
}
